<extend name="Base/common" />
<block name="body">
  <div class="span9 page_message">
    <section id="contents"> 
      <include file="Addons/_nav" /> 
      <if condition="$add_button || $del_button || $search_button">   
      <div class="table-bar">
        <div class="fl">
          <empty name="model.extend">
			<div class="tools">
				<a class="btn" href="{$re_url}">刷新</a>
				<if condition="$del_button"><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">拉取粉丝openid</button></if>
               <button id="updatafansemsg" class="btn confirm">更新粉丝信息</button>
                <a  class="btn" href="{:U('expUser')}" >导出数据并生成excel</a>
                <volist name="top_more_button" id="vo">
                <a class="btn" href="{$vo.url}">{$vo.title}</a>
                </volist>            
			</div>
          </empty>
        </div>
        <!-- 高级搜索 -->
        <if condition="$search_button">
        <div class="search-form fr cf">
          <div class="sleft">
            <php> $search_url || $search_url = addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists',array('model'=>$model['name']));</php>
            <input type="text" name="{$model['search_key']|default='title'}" class="search-input" value="{:I('title')}" placeholder="{$placeholder}">
            <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div>
        </div>
        </if>
      </div>
      </if>

      <!-- 数据列表 -->
      <div class="data-table">
        <div class="table-striped">
          <table cellspacing="1">
            <!-- 表头 -->
            <thead>
              <tr>
                <if condition="$check_all"><th style="display: none"  class="row-selected row-selected"> <input  type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label></th></if>
                <volist name="list_grids" id="field">
                  <th <notempty name="field.width">width="{$field.width}%"</notempty> >{$field.title}</th>
                </volist>
              </tr>
            </thead>
            
            <!-- 列表 -->
            <tbody>
              <volist name="list_data" id="data">
                <tr>
                  <if condition="$check_all"><td style="display: none"><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if>
                  <volist name="list_grids" id="grid">
                    <td>
                      <if condition="$grid['field'][0]=='thumbimg'"><img width="120" height="120" src="__ROOT__{$data['thumbimg']|get_cover='path'}"/>
                      <else />
                        {:get_list_field($data,$grid,$model)}
                      </if>
                    </td>
                  </volist>
                </tr>
              </volist>
            </tbody>
          </table>
        </div>
      </div>
      <div class="page"> {$_page|default=''} </div>
    </section>
  </div>
</block>
<block name="script">
  <script type="text/javascript">
      var state=1;
      var page=0;
$(function(){
    //更新粉丝信息
    function updatfanse(alertmsag,content){
        $.get("{$updatefanse}/page/"+page+".html",function(data){
            page++;
              content.text("当前更新进度"+data.baifen+"%");
            if(data.baifen<=100){
                updatfanse(alertmsag,content);
            }else{
                content.text("更新完成");
                setTimeout(function(){
                    location.reload();
                },2000);
                state=1;
            }
        });
    }
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $("#updatafansemsg").click(function(){
        var alertmsag=$("#top-alert");
        var content=$("#top-alert .alert-content");
        alertmsag.attr("class","top-alert-tips alert-success");
        content.text("当前更新进度0%");
        alertmsag.show();
        if(state){
            state=0;
            updatfanse(alertmsag,content);
        }else{
            content.text("正在更新请稍低....");
        }

    });

})
</script> 
</block>
